package com.atguigu.d_stream_filter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;

public class Demo {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Integer> list = new ArrayList<>();
        //批量添加元素
        Collections.addAll(list,1,2,3,4,5,6,7,8,9);
        //进工厂
        Stream<Integer> stream = list.stream();

        //进车间
        //所有的Lambda表达式和方法引用和链式编程  --> 自己改  !!
        Stream<Integer> stream1 = stream.filter(new Predicate<Integer>() {
            @Override
            public boolean test(Integer integer) {
                return integer >= 5;
            }
        });

        //出工厂
        stream1.forEach(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.println(integer);
            }
        });
    }
}
